<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入vue2的js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
    <style>
        span{
            margin-right:10px;
        }
    </style>
</head>

<body>
    <div id="app">
        <login></login>
        <hr />
        <login></login>
        <hr />
        <login></login>
    </div>

    <script>
        Vue.component('login', {
            template: `
            <div>
                <p><span>用户名:</span><input type="text" v-model="userName"></p>
                <p><span>密码:</span><input type="text" v-model="passWord"></p>
                <button @click="login">登录</button>
            </div>
            `,
            data() {
                return {
                    userName: '',
                    passWord: ''
                }
            },
            methods: {
                login() {
                    console.log(this.userName, this.passWord);
                }
            }
        })

        new Vue({
            el: '#app',
        })
    </script>
</body>

</html>